package com.zj.aopspringboot01;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component //将切面类声明为一个bean
@Aspect //声明这是一个切面类
public class LogAspect2 {
    //只有AfterReturning和Around可以获得返回值
    //AfterReturning中获取返回值要显示标出返回值名称：returning=xxx
    //https://blog.csdn.net/weixin_39919948/article/details/114765825
    @AfterReturning(value = "execution(* com.zj.aopspringboot01.UserService.*(..))",returning = "returnValue")
    public void logAdd(JoinPoint joinPoint, Object returnValue) {
        System.out.println("AfterReturning: " + returnValue);
    }
}
